<?php

namespace  Aitels\Foundation\Annotation;


class ScheduleAnnotation extends Annotation implements AnnotationInterface
{
    public const NAME = 'schedule';

    public function patten(): string
    {
        return '/@Schedule\((.+)\)/';
    }

    public function processMatches(array $matches)
    {
        $definitions = [];
        foreach ($matches[1] as $inParentheses) {
            $definition = $this->extractToParts($inParentheses);
            $parsed = [];
            foreach ($definition as $part) {
                if (strpos($part, '=') !== false) {
                    list($left, $right) = explode('=', $part);
                    $right = explode(',', $right);
                    $parsed[$left] = $right;
                } else {
                    $parsed[] = $part;
                }
            }
            $definitions[] = $parsed;
        }

        return $definitions;
    }


}